How to programmatically set page settings in novaPDF SDK
-
- Posts: 284
- Joined: Wed Dec 16, 2009 12:46 pm
How to programmatically set page settings in novaPDF SDK
novaPDF SDK allows the developers to setup any page related settings by using the available parameters. For a sample code and a detailed article on how to do this, access http://www.novapdf.com/kb/how-to-set-pr ... k-112.html
Follow us to stay updated:
- Newsletter (get a discount for subscribing): https://www.novapdf.com/newsletter.html
- Facebook: https://www.facebook.com/novapdf
- Twitter: https://twitter.com/novapdf
- Linkedin: https://www.linkedin.com/showcase/novapdf
Re: How to programmatically set page settings in novaPDF SDK
Hi Iam using novaPDF SDK for PDF generation in C# language.
I have a problem in setting the page size as A4.
The following is the portion of the code where i set the page size.
//set page size to A4
myNovaPDFOptions.SetOptionLong2(NOVAPDF_PAGE_SIZE, DMPAPER_A4, TPS_PROFILE, PROFILE_IS_PUBLIC);
//Page Form - select default page form as A4
myNovaPDFOptions.SetOptionString2(NOVAPDF_PAGE_FORM, PAGEFORM_A4, TPS_PROFILE, PROFILE_IS_PUBLIC);
myNovaPDFOptions.SetOptionLong2("OverridePaper", 1, TPS_PROFILE, PROFILE_IS_PUBLIC);
Once this is done, printing is done but document is generated with the last selected page size in the page Tab of printing preferences dialog and not with A4, even if the selection is showing as A4 in page tab.
Please let me know whether i am doing it wrong.
I have a problem in setting the page size as A4.
The following is the portion of the code where i set the page size.
//set page size to A4
myNovaPDFOptions.SetOptionLong2(NOVAPDF_PAGE_SIZE, DMPAPER_A4, TPS_PROFILE, PROFILE_IS_PUBLIC);
//Page Form - select default page form as A4
myNovaPDFOptions.SetOptionString2(NOVAPDF_PAGE_FORM, PAGEFORM_A4, TPS_PROFILE, PROFILE_IS_PUBLIC);
myNovaPDFOptions.SetOptionLong2("OverridePaper", 1, TPS_PROFILE, PROFILE_IS_PUBLIC);
Once this is done, printing is done but document is generated with the last selected page size in the page Tab of printing preferences dialog and not with A4, even if the selection is showing as A4 in page tab.
Please let me know whether i am doing it wrong.
-
- Posts: 284
- Joined: Wed Dec 16, 2009 12:46 pm
Re: How to programmatically set page settings in novaPDF SDK
Hello,
As we mentioned in above article, we do not recommend you set the page size from novaPDF settings. The reason is that only novaPDF will know and use this setting when saving the PDF file, but the application from where the print job is started will still use the old page size for formatting the content of the pages. So we recommend you setup the page size in your document class instead of novaPDF settings.
We tested the code you used to setup page size in novaPDF and indeed it does not work as expected. We found a problem in our driver and we will correct it from the next build of novaPDF (build no. 335). If you still wish to use the Override Paper option from novaPDF, please upgrade to build 335 when available.
Thank you.
As we mentioned in above article, we do not recommend you set the page size from novaPDF settings. The reason is that only novaPDF will know and use this setting when saving the PDF file, but the application from where the print job is started will still use the old page size for formatting the content of the pages. So we recommend you setup the page size in your document class instead of novaPDF settings.
We tested the code you used to setup page size in novaPDF and indeed it does not work as expected. We found a problem in our driver and we will correct it from the next build of novaPDF (build no. 335). If you still wish to use the Override Paper option from novaPDF, please upgrade to build 335 when available.
Thank you.
Follow us to stay updated:
- Newsletter (get a discount for subscribing): https://www.novapdf.com/newsletter.html
- Facebook: https://www.facebook.com/novapdf
- Twitter: https://twitter.com/novapdf
- Linkedin: https://www.linkedin.com/showcase/novapdf
Re: How to programmatically set page settings in novaPDF SDK
Hi I have gone through your reply.what i am trying to do is overriding the printer settings at the system level.so that when ever we print through the application nova will take the updated settings.
Here is some prototyped code(Code in C#) but even after writing this code nova is still not able to take updated settings.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
AddTPSProfile();
ComboBox aCombo = sender as ComboBox;
PageSettings aPageSettings = new PageSettings();
PaperSize aPaperSize = new PaperSize();
aPaperSize.RawKind = GetPaperSize(aCombo.SelectedItem.ToString()); ;
aPageSettings.PaperSize = aPaperSize;
System.Drawing.Printing.PrinterSettings aPrinterSettings = new System.Drawing.Printing.PrinterSettings();
aPrinterSettings.PrinterName = myPDFPrinterName;
aPageSettings.PrinterSettings = aPrinterSettings;
IntPtr aPtr = aPrinterSettings.GetHdevmode(aPageSettings);
aPrinterSettings.SetHdevmode(aPtr);
aPrinterSettings.DefaultPageSettings.SetHdevmode(aPtr);
MessageBox.Show("Paper Size Setting Finished");
}
private int GetPaperSize(string theSelection)
{
switch (theSelection)
{
case "A4":
return 9;
case "A5":
return 11;
case "A6":
return 70;
case "Legal":
return 5;
case "Letter":
return 1;
default:
throw new NotSupportedException("Page size Not supported : " + theSelection);
}
}
Here is some prototyped code(Code in C#) but even after writing this code nova is still not able to take updated settings.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
AddTPSProfile();
ComboBox aCombo = sender as ComboBox;
PageSettings aPageSettings = new PageSettings();
PaperSize aPaperSize = new PaperSize();
aPaperSize.RawKind = GetPaperSize(aCombo.SelectedItem.ToString()); ;
aPageSettings.PaperSize = aPaperSize;
System.Drawing.Printing.PrinterSettings aPrinterSettings = new System.Drawing.Printing.PrinterSettings();
aPrinterSettings.PrinterName = myPDFPrinterName;
aPageSettings.PrinterSettings = aPrinterSettings;
IntPtr aPtr = aPrinterSettings.GetHdevmode(aPageSettings);
aPrinterSettings.SetHdevmode(aPtr);
aPrinterSettings.DefaultPageSettings.SetHdevmode(aPtr);
MessageBox.Show("Paper Size Setting Finished");
}
private int GetPaperSize(string theSelection)
{
switch (theSelection)
{
case "A4":
return 9;
case "A5":
return 11;
case "A6":
return 70;
case "Legal":
return 5;
case "Letter":
return 1;
default:
throw new NotSupportedException("Page size Not supported : " + theSelection);
}
}
-
- Posts: 284
- Joined: Wed Dec 16, 2009 12:46 pm
Re: How to programmatically set page settings in novaPDF SDK
Hello,
As mentioned before, the override paper option has been fixed in build no. 335. If that still cannot help you in achieving the goal with the script you have created, unfortunately we cannot help you in troubleshooting the issue.
Thank you for understanding.
As mentioned before, the override paper option has been fixed in build no. 335. If that still cannot help you in achieving the goal with the script you have created, unfortunately we cannot help you in troubleshooting the issue.
Thank you for understanding.
Follow us to stay updated:
- Newsletter (get a discount for subscribing): https://www.novapdf.com/newsletter.html
- Facebook: https://www.facebook.com/novapdf
- Twitter: https://twitter.com/novapdf
- Linkedin: https://www.linkedin.com/showcase/novapdf