Questions about Aspose Total for .NET/Java and both

@praveen043,

And, regarding PPT file format issue, kindly try our latest version/fix: Aspose.Slides v18.7, it should fix your issue.

Let us know if you still have any issue.

Please provide the Watermarking java source code for image files.

Water mark not working at all pages. Please refer the below source code–

private static void insertWatermarkText(Document doc, String watermarkText) throws Exception

{

// Create a watermark shape. This will be a WordArt shape.

// You are free to try other shape types as watermarks.

Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);

// Set up the text of the watermark.

watermark.getTextPath().setText(watermarkText);

watermark.getTextPath().setFontFamily( "Arial" );

watermark.setWidth( 500 );

watermark.setHeight( 100 );

// Text will be directed from the bottom-left to the top-right corner.

watermark.setRotation(- 40 );

// Remove the following two lines if you need a solid black text.

watermark.getFill().setColor(Color.GRAY); // Try LightGray to get more Word-style watermark

watermark.setStrokeColor(Color.GRAY); // Try LightGray to get more Word-style watermark

// Place the watermark in the page center.

watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);

watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);

watermark.setWrapType(WrapType.NONE);

watermark.setVerticalAlignment(VerticalAlignment.CENTER);

watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);

// Create a new paragraph and append the watermark to this paragraph.

Paragraph watermarkPara = new Paragraph(doc);

watermarkPara.appendChild(watermark);

// Insert the watermark into all headers of each document section.

for (Section sect : doc.getSections())

{

// There could be up to three different headers in each section, since we want

// the watermark to appear on all pages, insert into all headers.

insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_PRIMARY);

// insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_FIRST);

// insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_EVEN);

}

}

private static void insertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, int headerType) throws Exception

{

HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(headerType);

if (header == null )

{

// There is no header of the specified type in the current section, create it.

header = new HeaderFooter(sect.getDocument(), headerType);

sect.getHeadersFooters().add(header);

}

// Insert a clone of the watermark into the header.

header.appendChild(watermarkPara.deepClone( true ));

}

@praveen043,

For your following requirements:

    private void StampWatermarkOnRaster(Image image)
    {
        int watermarkWidth = 230;
        int watermarkHeight = 50;
        Font watermarkFont = new Font("Arial", 10);
        Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
        brush.Color = Color.Black;
        Pen pen = new Pen(Color.Red, 2);
        Aspose.Imaging.Brushes.SolidBrush backBrush = new Aspose.Imaging.Brushes.SolidBrush(Color.White);

        // simple raster watermarking
        Graphics graphics = new Graphics(image);
        graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
        if (watermarkHeight < image.Height && watermarkWidth < image.Width)
        {
            graphics.FillRectangle(backBrush, 0, 0, watermarkWidth, watermarkHeight);
            graphics.DrawString(EvaluationMessage, watermarkFont, brush, new Aspose.Imaging.PointF(0, 0));
        }
        else
        {
            graphics.DrawLine(pen, 0, 0, image.Width - 1, image.Height - 1);
            graphics.DrawLine(pen, image.Width - 1, 0, 0, image.Height - 1);
        }
    }

This is java code “Aspose.Imaging.Brushes.SolidBrush”?

@praveen043,

Please try using following Java code on your end to serve the purpose.

private void StampWatermarkOnRaster(Image image)
{
    int watermarkWidth = 230;
    int watermarkHeight = 50;
    Font watermarkFont = new Font("Arial", 10);
    com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush();
    brush.setColor(Color.getBlack());
    Pen pen = new Pen(Color.getRed(), 2);
    com.aspose.imaging.brushes.SolidBrush backBrush = new com.aspose.imaging.brushes.SolidBrush(Color.getWhite());

    // simple raster watermarking
    Graphics graphics = new Graphics(image);
    graphics.setTextRenderingHint(TextRenderingHint.SingleBitPerPixelGridFit);
    if (watermarkHeight < image.getHeight() && watermarkWidth < image.getWidth())
    {
        graphics.fillRectangle(backBrush, 0, 0, watermarkWidth, watermarkHeight);
        graphics.drawString("EvaluationMessage", watermarkFont, brush, new com.aspose.imaging.PointF(0, 0));
    }
    else
    {
        graphics.drawLine(pen, 0, 0, image.getWidth() - 1, image.getHeight() - 1);
        graphics.drawLine(pen, image.getWidth() - 1, 0, 0, image.getHeight() - 1);
    }
}

We have change the code it’s working. But i have not got the appropriate output as per our requirement. Same problem with PPT also.

Please find the attached document for the same.new_change_201884_2323.jpeg (66.8 KB)
PPT.png (130.9 KB)

@praveen043

Would you please share your sample input files (i.e. Source Image and PPT) with us. We will test the scenario in our environment and address it accordingly.

Please find the attached sample file and source codeCapture.png (2.9 KB)
B.zip (22.3 KB)

PPT–

com.aspose.slides.Presentation pres = new com.aspose.slides.Presentation(path + fileName);
com.aspose.slides.IMasterSlide master = pres.getMasters().get_Item(0);
com.aspose.slides.IAutoShape ashp = master.getShapes().addAutoShape(
com.aspose.slides.ShapeType.Rectangle, 10, 10, 300, 300);
ashp.addTextFrame(“Confidential”);
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions()
.get_Item(0).getPortionFormat().setFontHeight(25);
master.getShapes().reorder(0, ashp);
ashp.getAutoShapeLock().setSelectLocked(true);
ashp.getAutoShapeLock().setSizeLocked(true);
ashp.getAutoShapeLock().setTextLocked(true);
ashp.getAutoShapeLock().setPositionLocked(true);
ashp.getAutoShapeLock().setGroupingLocked(true);

	pres.save(path + "confidentieldata\\" + fileName,
			com.aspose.slides.SaveFormat.Pptx);

Image—

com.aspose.imaging.Image image = com.aspose.imaging.Image.load(path+fileName);

int watermarkWidth = 230;
int watermarkHeight = 50;
com.aspose.imaging.Font watermarkFont = new com.aspose.imaging.Font(“Arial”, 10);
com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush();
brush.setColor(com.aspose.imaging.Color.getBlack());
com.aspose.imaging.Pen pen = new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2);
com.aspose.imaging.brushes.SolidBrush backBrush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getWhite());

    // simple raster watermarking
    com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image);
    graphics.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.SingleBitPerPixelGridFit);
    if (watermarkHeight < image.getHeight() && watermarkWidth < image.getWidth())
    {
        graphics.fillRectangle(backBrush, 0, 0, watermarkWidth, watermarkHeight);
        graphics.drawString("Confidential", watermarkFont, brush, new com.aspose.imaging.PointF(0, 0));
    }
    else
    {
        graphics.drawLine(pen, 0, 0, image.getWidth() - 1, image.getHeight() - 1);
        graphics.drawLine(pen, image.getWidth() - 1, 0, 0, image.getHeight() - 1);
    }

    image.save(path + "confidentieldata\\" + fileName);

@praveen043,

Can you please share the details of issue incurring on your end. Please share the details so that I may help you further in this regard.

The water marking not working on PPT and image file. It’s showing evaluation copy right of company tool.

@praveen043,

I suggest you to please try using Aspose.Slides license to avoid evaluation watermark and setting watermark. For your further reference, please visit this documentation link.

A post was split to a new topic: Quotation for Aspose.Total for Java