How to programmatically set page settings in novaPDF SDK

Post here any questions/suggestions you have about novaPDF SDK or novaPDF OEM.
Post Reply
Support
Posts: 223
Joined: Wed Dec 16, 2009 12:46 pm

How to programmatically set page settings in novaPDF SDK

Post by Support » Wed Apr 14, 2010 8:08 am

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

Roshni

Re: How to programmatically set page settings in novaPDF SDK

Post by Roshni » Mon May 03, 2010 9:00 am

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.

Support
Posts: 223
Joined: Wed Dec 16, 2009 12:46 pm

Re: How to programmatically set page settings in novaPDF SDK

Post by Support » Tue May 04, 2010 9:18 am

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.

Mohit Bhandari

Re: How to programmatically set page settings in novaPDF SDK

Post by Mohit Bhandari » Tue May 11, 2010 5:51 am

I

Mohit Bhandari

Re: How to programmatically set page settings in novaPDF SDK

Post by Mohit Bhandari » Tue May 11, 2010 6:00 am

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);

}
}

Support
Posts: 223
Joined: Wed Dec 16, 2009 12:46 pm

Re: How to programmatically set page settings in novaPDF SDK

Post by Support » Thu May 27, 2010 9:17 am

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.

Post Reply