add custom document properties

The PDF Creator .NET Library enables you to create secure PDF documents on the fly and to view, print and process existing PDF documents. If you have any questions about PDF Creator .Net, please post them here.
Post Reply
hackl
Posts: 6
Joined: Mon Aug 30 2010

add custom document properties

Post by hackl » Wed Mar 09 2016

Hello,

how can I add custom properties on pdf-page "custom" programmatically?

I found nothing in the documentation nor on internet.

Greetings,
Georg

Jose
Amyuni Team
Posts: 549
Joined: Tue Oct 01 2002
Contact:

Re: add custom document properties

Post by Jose » Mon Mar 21 2016

Hi,

The link below points to our online documentation. Here you can find more information about adding custom attributes.

https://www.amyuni.com/WebHelp/Amyuni_P ... Method.htm

Example:

Code: Select all

    'Create a text
    With page.CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text1")
        .AttributeByName("Left").Value = 1000
        .AttributeByName("Top").Value = 0
        .AttributeByName("Right").Value = 3250
        .AttributeByName("Bottom").Value = 500
        .AttributeByName("BackColor").Value = 192
        .AttributeByName("Hyperlink").Value = "http://www.amyuni.com"
        .AttributeByName("Text").Value = "Amyuni Technologies"
 
        'Create a new attribute named Custom and set its value
        .AddAttribute("Custom", Amyuni.PDFCreator.IacAttributeType.String)
        .Attribute("Custom").Value = "Custom Value"
 
        'retrieve the value for testing
        MsgBox(.Attribute("Custom").Value.ToString)
    End With
Get PDF Suite, the expert .NET developer toolkit for PDF conversion, creation and editing - www.amyuni.com/pdfsuite

hackl
Posts: 6
Joined: Mon Aug 30 2010

Re: add custom document properties

Post by hackl » Wed Jun 29 2016

Hi Jose,

it definitively doesn't work! "Tuev Rheinland Service GmbH" appears but no custom property named "Tuev"! What is wrong with the code!?
Product\Version: PDF Creator .NET PRO Developer\5.5.0.7

Greetings,
Georg

var pdfDocument = new IacDocument();

var password = string.Empty;

if (pdfDocument.Open(fileRead, password))
{
fileRead.Close();

var fileWrite = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Read);

var page = pdfDocument.GetPage(1);
pdfDocument.ReportState = IacReportState.acReportStateDesign;

//Create a text

using (IacObject text = page.CreateObject(IacObjectType.acObjectTypeText, "acObjectTypeText"))
{
text.AttributeByName("Left").Value = 1000;
text.AttributeByName("Top").Value = 0;
text.AttributeByName("Right").Value = 3250;
text.AttributeByName("Bottom").Value = 500;
text.AttributeByName("BackColor").Value = 192;
text.AttributeByName("Text").Value = "Tuev Rheinland Service GmbH";

//Create a new attribute named Custom and set its value
text.AddAttribute("Tuev", IacAttributeType.String);
text.Attribute("Tuev").Value = "Tuev Value";
}

if (pdfDocument.Save(fileWrite, iacFileSaveOption))

Jose
Amyuni Team
Posts: 549
Joined: Tue Oct 01 2002
Contact:

Re: add custom document properties

Post by Jose » Wed Jun 29 2016

Hi,

Not sure why you are encountering this issue but the code below adds the custom attribute.

Can you send your PDF document and your resulting PDF document to support@amyuni.com? I will re-test your issue using that document

Code: Select all

using (IacObject text = page.CreateObject(IacObjectType.acObjectTypeText, "acObjectTypeText"))
{
    text.AttributeByName("Left").Value = 1000;
    text.AttributeByName("Top").Value = 0;
    text.AttributeByName("Right").Value = 3250;
    text.AttributeByName("Bottom").Value = 500;
    text.AttributeByName("BackColor").Value = 192;
    text.AttributeByName("Text").Value = "Tuev Rheinland Service GmbH";

    //Create a new attribute named Custom and set its value
    text.AddAttribute("Tuev", IacAttributeType.String);
    text.Attribute("Tuev").Value = "Tuev Value";
    MessageBox.Show(text.Attribute("Tuev").Value.ToString());
}

pdfDocument.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveAll);
Get PDF Suite, the expert .NET developer toolkit for PDF conversion, creation and editing - www.amyuni.com/pdfsuite

Post Reply