Evaluating Aspose.PDF for Dummies


#21

@Toberville

In case you want to add text and images at the center of the PDF Page, you may please achieve this using TextStamp and ImageStamp Classes. Furthermore, you may achieve this requirement by implementing single method as following:

public static void PrepareDocument(string inputDoc, string outputPath, string imageFile)
{
  Document doc = new Document(inputDoc);
  // if new page is needed
  //doc.Pages.Add();
  // select page where you want to add text and image
  Page page = doc.Pages[1];

  TextStamp textStamp = new TextStamp("Dummy text");
  // set text properties
  textStamp.TextState.Font = FontRepository.FindFont("Arial");
  textStamp.TextState.FontSize = Convert.ToSingle(10);
  textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.OrangeRed);
  textStamp.VerticalAlignment = VerticalAlignment.Center;
  textStamp.HorizontalAlignment = HorizontalAlignment.Center;

  page.AddStamp(textStamp);
            
  ImageStamp imageStamp = new ImageStamp(imageFile);
  imageStamp.HorizontalAlignment = HorizontalAlignment.Center;
  imageStamp.VerticalAlignment = VerticalAlignment.Center;
  imageStamp.TopMargin = imageStamp.Height + 10; // 10 points are for margin

  page.AddStamp(imageStamp);

  doc.Save(outputPath);
}

#22

Good Examples Asad… I can use your examples as a good model for my needs.

About text… How would I display a rectangle of formatted text? The text would have a couple paragraphs, bolds, italics, and maybe some sections where the font size is slightly larger. The rectangle size would always be the same but the formatted text would by dynamic; meaning I would pass it as a string from classic asp to the COM Wrapper. Any ideas? Maybe the string could be coded in HTML or some other something where I parse the string.

On another note, is it possible to use one parameter to designate colors (like the hexidecimal numbers used Photoshop)? This would simplify my coding because I can send one parameter to the COM Wrapper to designate a color.

Thanks for all you help? You rock!


#23

@Toberville

Would you please share a sample expected PDF document with us. It would help us understanding the scenario/requirements better. We will surely proceed further to assist you accordingly.


#24

toberville-ouput.pdf (5.1 MB)
toberville-input.pdf (5.0 MB)
toberville-notes.pdf (2.2 MB)

Great! I uploaded 3 files that give a general description of what I am trying today. I look forward to your expertise and thought provoking techniques.


#25

@Toberville

We are checking feasibility of your requirements and will share our feedback with you in a while.


#26

@Toberville

We appreciate your patience and cooperation.

We have noticed that you have mentioned almost similar requirements that have been addressed in another topic created by you. Please follow up in respective topic for further information or feel free to let us know if you have any further concerns related to this topic.